//
//  TSWalletTableViewCell.swift
//  TSProfitProject
//
//  Created by TMS on 2019/11/8.
//  Copyright © 2019 TMS. All rights reserved.
//

import UIKit

class TSWalletTableViewCell: UITableViewCell {

    var titleLabel : UILabel!
    var valueLabel : UILabel!
    var line : UIView!
    var cellModel : TSNormalCellModel?

    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        configViews()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    public func setupCell(model : TSNormalCellModel, last:Bool) {
        cellModel = model
        titleLabel.text = model.title
        valueLabel.text = model.value
        line.isHidden = last
    }
    
    func configViews() {
        titleLabel = UILabel.init()
        titleLabel.textColor = UIColor.hexadecimalColor(hexadecimal: "#323232")
        titleLabel.font = UIFont.systemFont(ofSize: 16, weight: .regular)
        contentView.addSubview(titleLabel)
        titleLabel.snp.makeConstraints { (make) in
            make.left.top.equalTo(15)
        }
        
        valueLabel = UILabel.init()
        valueLabel.textColor = UIColor.hexadecimalColor(hexadecimal: "#969696")
        valueLabel.font = UIFont.systemFont(ofSize: 12, weight: .regular)
        contentView.addSubview(valueLabel)
        valueLabel.snp.makeConstraints { (make) in
            make.left.equalTo(titleLabel)
            make.top.equalTo(titleLabel.snp_bottom).offset(7)
        }
        
        let icon = UIImageView.init(image: UIImage(named: "general_more"))
        contentView.addSubview(icon)
        icon.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().inset(15)
        }
        
        line = UIView.init()
        line.backgroundColor = UIColor.hexadecimalColor(hexadecimal: "#F3F8FB")
        contentView.addSubview(line)
        line.snp.makeConstraints { (make) in
            make.left.right.bottom.equalToSuperview()
            make.height.equalTo(1)
        }
    }

}
